library {{pubName}}.api;

import 'package:http/io_client.dart';
import 'package:dio/dio.dart';
import 'package:built_value/serializer.dart';
import 'package:{{pubName}}/serializers.dart';
{{#apiInfo}}{{#apis}}import 'package:{{pubName}}/api/{{classFilename}}.dart';
{{/apis}}{{/apiInfo}}

class {{clientName}} {

    Dio dio;
    Serializers serializers;
    String basePath = "http://petstore.swagger.io/v2";

    {{clientName}}({this.dio, Serializers serializers}) {
    if (dio == null) {
        BaseOptions options = new BaseOptions(
            baseUrl: basePath,
            connectTimeout: 5000,
            receiveTimeout: 3000,
        );
        this.dio = new Dio(options);
    }

    this.serializers = serializers ?? standardSerializers;
}

{{#apiInfo}}{{#apis}}
    /**
    * Get {{classname}} instance, base route and serializer can be overridden by a given but be careful,
    * by doing that all interceptors will not be executed
    */
    {{classname}} get{{classname}}() {
    return {{classname}}(dio, serializers);
    }

{{/apis}}{{/apiInfo}}
}